function FireWork(options = {}){
    this.box = options.box || document.querySelector('.box');
    this.skyInfo = {
        width:this.box.offsetWidth,
        height:this.box.offsetHeight
    }
    this.setSky(options)
    this.bindEvent();
}

FireWork.prototype.setSky = function(options){
    console.log(this);
    this.box.style.width = options.skyWidth + 'px'
    this.box.style.height = options.skyHeight + 'px'
    this.box.style.backgroundColor = options.skyColor
}

FireWork.prototype.bindEvent = function(){
    console.log(this);
    this.box.addEventListener('click',e =>{
        const b = document.createElement('b');
        let b_left = e.pageX - this.box.offsetLeft,
            b_top = e.pageY - this.box.offsetTop;
        css(b,'display','block');
        css(b,'width', 10 + 'px');
        css(b,'height',10 + 'px');
        css(b,'backgroundColor',getColor());
        css(b,'position','absolute');
        css(b,'left',b_left + 'px');    
        css(b,'top',this.skyInfo.height - parseInt(b.style.height) + 'px');
        this.box.appendChild(b);
        animate(b,{top:b_top},500,()=>{
            this.box.removeChild(b);
            const num = getRandom(20,30);
            const arr = [];
            for(let m = 0; m < num ; m++){
                const i = document.createElement('i');
                css(i,'width',b.style.width);
                css(i,'height',b.style.height);
                css(i,'backgroundColor',getColor());
                css(i,'position','absolute');
                css(i,'borderRadius','50%');
                css(i,'left',b_left + 'px');
                css(i,'top',b_top + 'px');
                this.box.appendChild(i);
                arr.push(i);
                for(let n= 0 ; n < arr.length ; n++){
                    animate(arr[n],{left:getRandom(0,this.skyInfo.width - parseInt(b.style.width)),top:getRandom(0,this.skyInfo.height - parseInt(b.style.height))},500,()=>{
                        this.box.removeChild(arr[n]);
                    })
                }
            }
        })
    })
}